import Vue from 'vue'
import Vuex from 'vuex'
import App from './App'
import store from './store'
import router from './router'
import './permission' // permission control
import Element from 'element-ui'
import api from './api/index.js'
import emojiList from './components/emoji/data.js'
import 'element-ui/lib/theme-chalk/index.css'
import './style/common.less'
import './filter/filter'
import './utils/dialog'
Vue.use(Element)
Vue.use(Vuex)

Vue.config.productionTip = false
Vue.prototype.$api = api
// 将评论的emoji文字转换为图片
Vue.prototype.transferComment = (msg) => {
  if (msg) {
    let reg = /\[[\u4E00-\u9FA5]{1,2}\]/g;
    let emojiData = emojiList()
    msg.replace(/\n/g, '<br/>')
    let res = msg.match(reg)
    if (res) {
      res.forEach(val => {
        emojiData.forEach(item => {
          if (val == item.text) {
            msg = msg.replace(val, `<img src=${item.img} class='vertical-middle emoji-icon'>`)
          }
        })
      })
    }
    return `: ${msg}`
  }
}

/* eslint-disable no-new */
new Vue({
  store,
  components: { App },
  render: h => h(App),
  router
}).$mount('#app')

